package com.sihan.framework.etm.mapper;

import com.framework.mybatis.mapper.BaseMapper;
import com.sihan.framework.etm.dto.EtmDeviceMountDTO;
import com.sihan.framework.etm.dto.GetAllDeviceAlarmDTO;
import com.sihan.framework.etm.dto.GetByIdRecordDTO;
import com.sihan.framework.etm.dto.business.DeviceMountDTO;
import com.sihan.framework.etm.entity.EtmDeviceRecord;
import com.sihan.framework.etm.entity.baseData.EtmDeviceMount;
import com.sihan.framework.etm.entity.business.CollectionRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
 * (EtmDeviceMount)表数据库访问层
 *
 * @author makejava
 * @since 2022-05-20 16:04:47
 */
@Mapper
public interface EtmDeviceMountMapper extends BaseMapper<EtmDeviceMount, String> {


    EtmDeviceMount selectByDeviceIdEtmDeviceMount(@Param("deviceId") String deviceId,@Param("mountType")Integer mountType);

    EtmDeviceMount selectByDeviceId(@Param("deviceId") String deviceId);

    int giveBack(@Param("deviceId") String deviceId,
                 @Param("ticketCode") String ticketCode);

    int updateBack(@Param("deviceId") String deviceId,
                   @Param("ticketCode") String ticketCode);

    int insertAll(EtmDeviceMount etmDeviceMount);

    int updateAll(EtmDeviceMount etmDeviceMount);

    int updateBydeviceId(@Param("deviceId")String deviceId);
    int deleteByMountType(@Param("deviceId")String deviceId);

    int updateBydeviceIdOne(@Param("deviceId")String deviceId,@Param("endTime")Date endTime);

    //统计接地线使用次数 mountType为空时 不分是非挂接异常
    List<DeviceMountDTO> selectByDeviceIdGetMountType(@Param("OrgId") String OrgId, @Param("mountType") Integer mountType);

    List<EtmDeviceMountDTO> getEtmDeviceMountList(@Param("deviceId") String deviceId,
                                                  @Param("startTime") Date startTime,
                                                  @Param("endTime") Date endTime,
                                                  @Param("mountType") Integer mountType,
                                                  @Param("startDate") Date startDate,
                                                  @Param("endDate") Date endDate);


    List<EtmDeviceMountDTO> EtmDeviceMountList(@Param("deviceId") String deviceId,
                                                  @Param("startTime") Date startTime,
                                                  @Param("endTime") Date endTime,
                                                  @Param("mountType") Integer mountType,
                                                  @Param("startDate") Date startDate,
                                                  @Param("endDate") Date endDate);

    /**
     * 根据条件查询设备使用情况
     *
     * @param deviceName
     * @param deviceCode
     * @param startTime
     * @param endTime
     * @param mountType
     * @param mountState
     * @return
     */
    List<EtmDeviceMountDTO> getEtmDeviceMountAll(@Param("deviceName") String deviceName,
                                                 @Param("deviceCode") String deviceCode,
                                                 @Param("orgIds") String[] orgIds,
                                                 @Param("deviceId") String deviceId,
                                                 @Param("startTime") Date startTime,
                                                 @Param("endTime") Date endTime,
                                                 @Param("mountType") Integer mountType,
                                                 @Param("mountState") Integer mountState,
                                                 @Param("deviceType") Integer deviceType);


    List<EtmDeviceMountDTO> getALLEtmDeviceMount(@Param("deviceName") String deviceName,
                                                 @Param("deviceCode") String deviceCode,
                                                 @Param("orgIds") String[] orgIds,
                                                 @Param("deviceId") String deviceId,
                                                 @Param("startTime") Date startTime,
                                                 @Param("endTime") Date endTime,
                                                 @Param("mountType") Integer mountType,
                                                 @Param("deviceType") String deviceType);

    List<GetAllDeviceAlarmDTO> getAllDeviceAlarm(@Param("deviceName") String deviceName,
                                                 @Param("deviceCode") String deviceCode,
                                                 @Param("taskCode") String taskCode,
                                                 @Param("orgIds") String[] orgIds,
                                                 @Param("deviceId") String deviceId,
                                                 @Param("startTime") Date startTime,
                                                 @Param("endTime") Date endTime,
                                                 @Param("mountType") Integer mountType,
                                                 @Param("deviceType") String deviceType);




    int getEtmDeviceMountNum(@Param("orgIds") String[] orgIds,
                             @Param("startTime") Date startTime,
                             @Param("endTime") Date endTime);


    List<CollectionRecord> getCollectionRecord(@Param("orgIds") String[] orgIds,
                                               @Param("deviceCode") String deviceCode,
                                               @Param("deviceName") String deviceName,
                                               @Param("taskCode") String taskCode,
                                               @Param("startTime") Date startTime,
                                               @Param("typeId") Integer typeId,
                                               @Param("endTime") Date endTime,
                                               @Param("state")Integer state);

    List<CollectionRecord> wxGetCollectionRecord(@Param("orgIds") String[] orgIds,
                                               @Param("deviceCode") String deviceCode,
                                                 @Param("startTime") Date startTime,
                                               @Param("endTime") Date endTime,
                                               @Param("state")String state,
                                                 @Param("currentState") String currentState);

    List<GetByIdRecordDTO> getByIdRecord(@Param("startTime") Date startTime,
                                         @Param("endTime") Date endTime,
                                         @Param("startTheReturn") Date startTheReturn,
                                         @Param("endTheReturn") Date endTheReturn,
                                         @Param("taskCode")String taskCode,
                                         @Param("deviceId") String deviceId);

    List<EtmDeviceRecord> getEtmDeviceRecordList(@Param("deviceId") String deviceId);

}